package cn.hxz.service;

import cn.hxz.mapper.TeacherMapper;
import cn.hxz.pojo.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//老师业务逻辑
@Service
public class TeacherService {

    //将mapper注入到service类中
    @Autowired
    public TeacherMapper teacherMapper;

    /**
     * 查询所有记录
     * @param name
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public List<Teacher> selectAll(String name,
                                   int pageIndex, int pageSize) {
        return teacherMapper.selectAll(name, pageIndex, pageSize);
    }
    /**
     * 保存
     * @param teacher
     */
    public void insert(Teacher teacher) {
        teacherMapper.insert(teacher);
    }
    /**
     * 编辑
     * @param teacher
     */
    public void update(Teacher teacher) {
        teacherMapper.update(teacher);
    }
    /**
     * 删除
     * @param id
     */
    public void delete(int id) {
        teacherMapper.delete(id);
    }
    /**
     * 查询单条
     * @param id
     * @return
     */
    public Teacher selectOne(int id) {
        return teacherMapper.selectOne(id);
    }
}
